<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="pits.dto.EmployeeDTO"%>
<%@ page import="pits.dao.AdminEmployeeListDAO"%>
<%@ page import="java.util.List"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>

<portlet:defineObjects />

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript">
	function getForm(namespace, name) {
		return document.forms[namespace + name];
	}
 
	function submitForm(namespace, name, action, selectedEmpID) {
		var frm = getForm(namespace, name);
		frm.txtAction.value = action;
		frm.submitLink.value = "Menu.jsp";
		frm.selectedEmp.value = selectedEmpID;
		frm.submit();
	}
</script>

</head>

<body>
<form name="<portlet:namespace/>empListForm"
	action="<portlet:actionURL/>" method="post"><input type="hidden"
	name="txtAction" /> <input type="hidden" name="submitLink" /> <input
	type="hidden" name="selectedEmp" />
<table>
	<%
	List<EmployeeDTO> empList = new AdminEmployeeListDAO().getData();
	if (empList != null) {
	%>
	<tr class="title">
		<td colspan="2"><img
			src='<%=renderRequest.getContextPath() + "/img/HCMUTLogo.jpg" %>' />
		<h1><a href="#">Personal information tracking system </a></h1>
		<p>exploit the value of data</p>
		<hr />
		</td>
	</tr>

	<tr>
		<td colspan="2" align="right">Welcome, <%=session.getAttribute("userName").toString() %>
		| <a href="#"
			onclick="submitForm('<portlet:namespace/>','empListForm','home','')">Home</a>
		| <a href="#"
			onclick="submitForm('<portlet:namespace/>','empListForm','logout','')">Logout</a>
		</td>
	</tr>
	<tr>
		<td colspan="4">
		<h2 class="title">emp List</h2>
		</td>
	</tr>
	<tr>
		<td colspan="4">
		<table border="1" width="100%">
			<tr>
				<td colspan="6" align="right"><em><%=empList.size() %>
				emp(s) found</em></td>
			</tr>
			<tr>
				<td align="center" valign="middle">&nbsp;</td>
				<td align="center" valign="middle">Name</td>
				<td align="center" valign="middle">Birthdate</td>
				<td align="center" valign="middle">Address</td>
				<td align="center" valign="middle">Email</td>
				<td align="center" valign="middle">Phone</td>
			</tr>
			<%
				for (int i = 0; i < empList.size(); i++) {
				%>
			<tr>
				<td align="center" valign="middle">&nbsp;</td>
				<td align="center" valign="middle"><a href=#
					onclick="
							submitForm('<portlet:namespace />','empListForm','editEmployee','<%=empList.get(i).getEmpID() %>');
						">
				<%=empList.get(i).getName() %> </a></td>
				<td align="center" valign="middle"><%=empList.get(i).getBirthday() %></td>
				<td align="center" valign="middle"><%=empList.get(i).getAddress() %></td>
				<td align="center" valign="middle"><%=empList.get(i).getEmail() %></td>
				<td align="center" valign="middle"><%=empList.get(i).getPhone() %></td>
			</tr>
			<%
				}
				%>
			<tr>
				<td colspan="6"><input type="button" value="Cancel"
					onclick="
							submitForm('<portlet:namespace />', 'empListForm', 'home','');
						" />
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<%
	}
	%>
</table>
</form>
</body>
</html>